var o = getApp(), t = require("../../mybehaviors/location/location");

Component({
    behaviors: [ t ],
    properties: {
        datas: {
            type: null
        },
        component_id: {
            type: null
        },
        page_id: {
            type: null
        }
    },
    data: {
        address: "",
        point: {
            lat: "",
            lng: ""
        },
        city: "",
        web_view_url: "",
        photobzhaoxiang: "",
        saoyisao: "",
        line: "",
        bgcimg: "",
        bgccolor: ""
    },
    lifetimes: {
        attached: function() {},
        moved: function() {},
        detached: function() {}
    },
    attached: function() {},
    ready: function() {
        var o = this;
        this._getLocation(function(t, a) {
            o.setData({
                address: t.address,
                city: t.address_component.city ? t.address_component.city : t.address_component.province,
                point: a
            });
        });
        var t = this.data.datas, a = t.photograph_color, e = t.scan_color, i = t.preview_color;
        this.setData({
            photobzhaoxiang: a.isColor ? a.color : "#e8e8e8",
            saoyisao: e.isColor ? e.color : "#e8e8e8",
            line: i.isColor ? i.color : "#e8e8e8",
            bgcimg: 2 == i.isColor ? i.image : "",
            bgccolor: i.color || "#f8f8f8"
        });
    },
    pageLifetimes: {
        show: function() {},
        hide: function() {},
        resize: function() {}
    },
    methods: {
        tolocation: function() {
            var o = getCurrentPages(), t = o[o.length - 1], a = "/".concat(t.route, "?page_id=").concat(this.data.page_id);
            wx.setStorageSync("diyurl", a), wx.navigateTo({
                url: "/packageC/o2o/o2oLocation/o2oLocation?tag=diy"
            });
        },
        camera: function() {},
        scanCode: function() {
            var o = this;
            wx.scanCode({
                onlyFromCamera: !0,
                success: function(t) {
                    o.setData({
                        web_view_url: t.result
                    });
                }
            });
        },
        multipleMethod: function(t) {
            var a = t.detail.file, e = this, i = o.getNetAddresss("upload.uploadPic");
            wx.uploadFile({
                url: i,
                filePath: a.url,
                name: "file",
                success: function(o) {
                    var t = JSON.parse(o.data), a = t.result, i = (t.msg, t.data);
                    a && (console.log(i.img_url), wx.navigateTo({
                        url: "/packageI/scanpictureGoods/scanpictureGoods?url=" + i.img_url
                    }));
                    e.data.fileList;
                },
                fail: function(o) {}
            });
        },
        tosearch: function() {
            if (this.data.city) {
                var o = this.data.datas.search_type || "store";
                wx.navigateTo({
                    url: "/packageC/o2o/o2oSearchMultiple/o2oSearchMultiple?city=" + this.data.city + "&point=" + JSON.stringify(this.data.point) + "&search_type=" + o
                });
            } else wx.showToast({
                icon: "none",
                title: "请先选择城市",
                duration: 1e3
            });
        }
    }
});